package hit.example.adapter;

import hit.example.Object.ObjWord;
import hit.example.hitdict.R;

import java.util.ArrayList;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterListView extends ArrayAdapter<ObjWord>{

	Activity context;
	int LayoutID;
	ArrayList<ObjWord> listWord;
	public AdapterListView(Activity context,
			int textViewResourceId, ArrayList<ObjWord> objects) {
		super(context, textViewResourceId, objects);
		this.context=context;
		this.LayoutID=textViewResourceId;
		this.listWord=objects;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView=context.getLayoutInflater().inflate(LayoutID, null);
		TextView txtiWord=(TextView)convertView.findViewById(R.id.txtWord);
		ImageView imvArows=(ImageView)convertView.findViewById(R.id.imvIcon);
		
		
		txtiWord.setText(listWord.get(position).getiWord());
		return convertView;
	}
	
	public void setItems(ArrayList<ObjWord> items){
		clear();
		
		if(items!=null)
		for (ObjWord obj : items) {
			add(obj);
		}
		
		
	}
}
